package com.dream.service.recommender.base.entity;

import com.dream.service.recommender.toolkits.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zhiji on 2016/04/25.
 */
public class RequestParam {
    public Map<String, Object> params = new HashMap<String, Object>();

    public void addParam(String key, Object value) {
        if (!StringUtils.isEmpty(key)) {
            params.put(key, value);
        }
    }

    public Integer getInteger(String key) {
        if (StringUtils.isEmpty(key) || !params.containsKey(key)) {
            return null;
        }
        Object value = params.get(key);
        return (Integer) value;
    }

    public Long getLong(String key) {
        if (StringUtils.isEmpty(key) || !params.containsKey(key)) {
            return null;
        }
        Object value = params.get(key);
        return (Long) value;
    }

    public Object get(String key) {
        if (StringUtils.isEmpty(key) || !params.containsKey(key)) {
            return null;
        }
        Object value = params.get(key);
        return value;
    }

    public String getString(String key) {
        if (StringUtils.isEmpty(key) || !params.containsKey(key)) {
            return null;
        }
        Object obj = params.get(key);
        return obj == null ? null : obj.toString();
    }

}
